package com.qipay.baas.mapper;

import com.qipay.baas.model.Menu;
import com.qipay.baas.model.MenuExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.type.JdbcType;

public interface MenuMapper {
    @DeleteProvider(type=MenuSqlProvider.class, method="deleteByExample")
    int deleteByExample(MenuExample example);

    @Delete({
        "delete from menu",
        "where menu_id = #{menuId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer menuId);

    @Insert({
        "insert into menu (menu_uri, SUPERIOR_ID, ",
        "className, menu_name, ",
        "auth, isvalid)",
        "values (#{menuUri,jdbcType=VARCHAR}, #{superiorId,jdbcType=INTEGER}, ",
        "#{classname,jdbcType=VARCHAR}, #{menuName,jdbcType=VARCHAR}, ",
        "#{auth,jdbcType=VARCHAR}, #{isvalid,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="menuId", before=false, resultType=Integer.class)
    int insert(Menu record);

    @InsertProvider(type=MenuSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="menuId", before=false, resultType=Integer.class)
    int insertSelective(Menu record);

    @SelectProvider(type=MenuSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="menu_id", property="menuId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="menu_uri", property="menuUri", jdbcType=JdbcType.VARCHAR),
        @Result(column="SUPERIOR_ID", property="superiorId", jdbcType=JdbcType.INTEGER),
        @Result(column="className", property="classname", jdbcType=JdbcType.VARCHAR),
        @Result(column="menu_name", property="menuName", jdbcType=JdbcType.VARCHAR),
        @Result(column="auth", property="auth", jdbcType=JdbcType.VARCHAR),
        @Result(column="isvalid", property="isvalid", jdbcType=JdbcType.INTEGER)
    })
    List<Menu> selectByExampleWithRowbounds(MenuExample example, RowBounds rowBounds);

    @SelectProvider(type=MenuSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="menu_id", property="menuId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="menu_uri", property="menuUri", jdbcType=JdbcType.VARCHAR),
        @Result(column="SUPERIOR_ID", property="superiorId", jdbcType=JdbcType.INTEGER),
        @Result(column="className", property="classname", jdbcType=JdbcType.VARCHAR),
        @Result(column="menu_name", property="menuName", jdbcType=JdbcType.VARCHAR),
        @Result(column="auth", property="auth", jdbcType=JdbcType.VARCHAR),
        @Result(column="isvalid", property="isvalid", jdbcType=JdbcType.INTEGER)
    })
    List<Menu> selectByExample(MenuExample example);

    @Select({
        "select",
        "menu_id, menu_uri, SUPERIOR_ID, className, menu_name, auth, isvalid",
        "from menu",
        "where menu_id = #{menuId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="menu_id", property="menuId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="menu_uri", property="menuUri", jdbcType=JdbcType.VARCHAR),
        @Result(column="SUPERIOR_ID", property="superiorId", jdbcType=JdbcType.INTEGER),
        @Result(column="className", property="classname", jdbcType=JdbcType.VARCHAR),
        @Result(column="menu_name", property="menuName", jdbcType=JdbcType.VARCHAR),
        @Result(column="auth", property="auth", jdbcType=JdbcType.VARCHAR),
        @Result(column="isvalid", property="isvalid", jdbcType=JdbcType.INTEGER)
    })
    Menu selectByPrimaryKey(Integer menuId);

    @UpdateProvider(type=MenuSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Menu record, @Param("example") MenuExample example);

    @UpdateProvider(type=MenuSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Menu record, @Param("example") MenuExample example);

    @UpdateProvider(type=MenuSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Menu record);

    @Update({
        "update menu",
        "set menu_uri = #{menuUri,jdbcType=VARCHAR},",
          "SUPERIOR_ID = #{superiorId,jdbcType=INTEGER},",
          "className = #{classname,jdbcType=VARCHAR},",
          "menu_name = #{menuName,jdbcType=VARCHAR},",
          "auth = #{auth,jdbcType=VARCHAR},",
          "isvalid = #{isvalid,jdbcType=INTEGER}",
        "where menu_id = #{menuId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Menu record);
}